// This library provides WebAssembly bindings for the FreeCAD's geometric solver library planegcs.
// Copyright (C) 2023  Miroslav Šerý, Salusoft89 <miroslav.sery@salusoft89.cz>  
// Copyright (C) 2023  Jiří Hon, Salusoft89 <jiri.hon@salusoft89.cz>  

// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.

// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

import { SketchGeometryProperty } from "../sketch/geom_params";
import { {% for enum_name in import_enums %}{{ enum_name }}, {% endfor -%} } from "./enums";
import type { oid, Id } from "./id";

interface ObjectParam {
    o_id: oid;
    prop: SketchGeometryProperty;
}

{% for item in fn_constraints %}
export interface {{ item.constraint_name }} extends Id {
    type: '{{ item.constraint_type }}';
{%- for param in item.params_list -%}
    {% set optional = '?' if param.optional_value else '' -%}
    {% if param.type == 'double' and param.identifier[0] == '*' %}
    {{ param.identifier | replace('*', '') + optional}}: ObjectParam|number|string;
    {%- elif param.identifier == 'tagId' %} {# skip #}
    {%- elif param.type in ['double', 'int', 'unsigned double', 'unsigned int'] %}
    {{ param.identifier + optional }}: number;
    {%- elif param.type == 'bool' %}
    {{ param.identifier + optional }}: boolean;
    {%- elif param.is_enum %}
    {{ param.identifier + optional }}: {{ param.type | replace('::', '_') }};
    {%- else %} {# object (Line, Parabola, Point, ...) #}
    {{ param.identifier | replace('&', '') + optional }}_id: oid; // {{ param.type }}
    {%- endif %}
{%- endfor %}
    temporary?: boolean;
    scale?: number;
}
{% endfor %}

export type Constraint = {% for item in fn_constraints %}{{ item.constraint_name }}{%- if not loop.last %} | {% endif %}{% endfor %};
export type ConstraintParamType = {% for item in fn_constraints %}{{ item.constraint_name }}[keyof {{ item.constraint_name }}]{%- if not loop.last %} | {% endif %}{% endfor %};